import request from '@/utils/request'

// 用户主页
export function getInfoByName(username, page, size) {
    return request({
        url: '/ums/user/' + username,
        method: 'get',
        params: {
            pageNo: page,
            size: size
        },
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }

    })
}

// 用户主页
export function getInfo(username) {
    return request({
        url: '/ums/user/info',
        method: 'get',
        params: {
            username: username
        },
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }
    })
}

// 更新
export function update(user) {
    return request({
        url: '/ums/user/update',
        method: 'post',
        headers: {
            Authorization: localStorage.getItem('Authorization')
        },
        data: user
    })
}

export function findById(id) {
    return request({
        url: '/ums/user/id/' + id,
        method: 'get',
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }
    })
}

export function getInfoById(id) {
    return request({
        url: '/ums/user/info/' + id,
        method: 'get',
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }
    })
}

export function updateAvatar(fileName) {
    return request({
        url: '/ums/user/updateAvatar',
        method: 'post',
        params: {
            fileName: fileName
        },
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }
    })
}

export function updateUser(data) {
    return request({
        url: '/ums/user/update',
        method: 'post',
        data: data,
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }
    })
}